const Koa = require('koa')

const app = new Koa()

// ctx 上下文环境 把request 和response给封装了
// next
app.use(async(ctx,next) => {
  ctx.body = [
    {
      name:'tom'
    }
  ]
  await next()
})


app.use(async(ctx,next) => {
  const start = new Date().getTime()
  console.log(`start: ${ctx.url}`)
  await next()
  const end = new Date().getTime()
  console.log(`请求${ctx.url}耗时${end-start}`)
})






app.listen(3000)